<#assign pageTitle="我的消息"/>
<#assign pageHeader>
    <link rel="stylesheet" type="text/css" href="/static/h5/css/user.css?20220210"/>
    <style>
        .user-course-list{
            background-color: #ffffff;
        }
        hr{
            color: #c0c4cc;
            border-style:dotted;
        }
    </style>
</#assign>
<#assign pageContent>
    <van-nav-bar
            title="我的消息"
            left-text="返回"
            left-arrow
            @click-left="location.href='/user/index.html';"
            fixed
            placeholder
    ></van-nav-bar>
    <div class="main-item mt-12">
        <#if letterList?? && letterList?size gt 0>
            <div class="course-card">
                <#list letterList as item>
                    <van-row gutter="24">
                        <van-col span="24">
                            <div class="user-course-list">
                                <span @click="showPopup('${item.content!}')" class="fl" style="width: 90%">${item.content!}</span>
                                <span class="fl">${item.createTime!}</span>
                                <van-button class="fr" type="danger" @click="todel(${item.id})" size="mini">删 除</van-button>
                            </div>
                            <hr size=1>
                        </van-col>
                    </van-row>
                </#list>
            </div>
        <#else>
            <van-empty description="您还没有任何消息..."></van-empty>
        </#if>
    </div>
    <van-pagination v-if="pageCount != 0"  v-model="currentPage" :page-count="pageCount" mode="simple"  class="mb-12 pd-12" @change="pageChange"></van-pagination>
    <van-popup v-model="show" round position="bottom" :style="{ height: '30%' }" />
           <div style="padding: 20px;font-size: 18px">{{content}}</div>
    </van-popup>
</#assign>
<#assign pageScript>
    <script>
        var pageCount = ${totalPages}
        var currentPage = ${page.currentPage}
            new Vue({
                el: '#app',
                data() {
                    return {
                        showFooter: false,
                        show: false,
                        content: "",
                        pageCount : pageCount,
                        currentPage: currentPage
                    }
                },
                methods: {
                    pageChange(value) {
                        window.location.href = '/user/letter.html?page=' + value;
                    },
                    todel(id){
                        var that = this;
                        axios.get("/user/ajax/delLetterInbox", {
                            params: {
                                id: id
                            }
                        }).then(function (json) {
                            if (json.data.code === 0) {
                                window.location.reload()
                            }else {
                                that.$toast(json.data.msg);
                            }
                        }).catch(function (error) {
                            that.$toast(error);
                        });
                    },
                    showPopup(content) {
                        this.content = content;
                        this.show = true;
                    }
                }
            })
    </script>
</#assign>
<#include "../layout_h5.ftl" />